I'm writing a simple piece of code to let the client to be able to receive multicast UDPs to link-local all-node "ff02::1". But I encountered the following problem. Any comments?
I'm under Windows XP SP2. According to msdn IPPROTO_IPV6 page, it should be
supported by this OS. But the "setsockopt" line of code gives 10022(WSAEINVAL: The level parameter is not valid, or the information in optval parameter is not valid.)
IPV6_MREQ imr;
TCHAR *all_nodes = L"ff02::1";
//get IPv6 multicast address from string
if ( WSAStringToAddress(all_nodes, AF_INET6, NULL, (struct sockaddr *)&sin, &len) == SOCKET_ERROR)
{
...... //break out
}
//set option to join link-local all-nodes multicast group
imr.ipv6mr_interface = 0;
imr.ipv6mr_multiaddr = sin.sin6_addr; //all_nodes;
if (::setsockopt(m_sockBCastV6, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char *)&imr, sizeof(imr)) == SOCKET_ERROR)
{
...... //break out
}
I also tried other options at IPPROTO_IPV6, and the only option that didn't
give 10022 error is IPV6_MULTICAST_IF.
I'm using Visual C++ in Visual Studio 2005. And OS is Windows XP, SP2.
Any help would be highly appreciated!